<!DOCTYPE html>
<html lang="en">

	<head>
		<meta charset="UTF-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<meta name="description" content="">
		<meta name="author" content="">
		<title>消息中心</title>
		<!-- Bootstrap -->
		<link rel="stylesheet" type="text/css" href="layui/css/layui.css" />
		<link href="css/bootstrap.min.css" rel="stylesheet">
		<link rel="stylesheet" type="text/css" href="css/message.css">
		<link rel="stylesheet" type="text/css" href="font/iconfont.css">
		<!--[if lt IE 9]>
      <script src="https://cdn.jsdelivr.net/npm/html5shiv@3.7.3/dist/html5shiv.min.js"></script>
      <script src="https://cdn.jsdelivr.net/npm/respond.js@1.4.2/dest/respond.min.js"></script>
    <![endif]-->
	</head>

	<body>
		<!-- 顶部 -->
		<header style="position: fixed;z-index: 999;">
			<div class="header-left" onclick="javascript:history.back(-1);">返回</div>
			<div class="header-right">消息中心</div>
		</header>
		<div class="main-top" style="position: fixed;top: 50px;z-index: 999;">
			<div class="mt-left" onclick="getList('')">
				<p>消息总计</p>
				<span id="sumMsg">0</span>
			</div>
			<div class="mt-right" onclick="getList(0)">
				<p>未查收消息</p>
				<span id="noReadMsg">0</span>
			</div>
		</div>
		<!-- 主体部分 -->
		<div class="main">
			<div class="list" style="overflow-y: scroll;overflow-x: hidden;">
				<ul class="flow-default" id="LAY_demo1"></ul>
				</ul>
				<div style="height: 100px;">
					&nbsp;
				</div>
			</div>
		</div>
		<!-- 底部 -->
		<footer>
			<ul>
				<a href="index.html">
					<li style="border-right: 1px solid #fff;"><i class="iconfont">&#xe633;</i><span>首页</span></li>
				</a>
				<a href="bill.html">
					<li style="border-right: 1px solid #fff;"><i class="iconfont">&#xe754;</i><span>账单</span></li>
				</a>
				<a href="person.html">
					<li class="blue"><i class="iconfont">&#xe61a;</i><span>我的</span></li>
				</a>
			</ul>
		</footer>
	</body>
	<script src="js/jquery.min.js"></script>
	<script src="js/bootstrap.min.js"></script>
	<script src="js/message.js"></script>
	<script src="js/flexible.js"></script>
	<script src="js/vue.min.js"></script>
	<script src="layer/layer.js"></script>
	<script src="layui/layui.js"></script>
	<script>
		var img = '<img src="images/dot.png" alt="">';
		var html = '<li onclick="info(~)">\n' +
			'\t\t\t\t\t\t<i>~</i>\n' +
			'\t\t\t\t\t\t<div class="list-left">\n' +
			'\t\t\t\t\t\t\t<div class="title">瑞兰团队</div>\n' +
			'\t\t\t\t\t\t\t<p>~</p>\n' +
			'\t\t\t\t\t\t</div>\n' +
			'\t\t\t\t\t\t<div class="list-right">\n' +
			'\t\t\t\t\t\t\t<span>~</span>\n' +
			'\t\t\t\t\t\t</div>\n' +
			'\t\t\t\t\t</li>';
		getList("");
		function getList(val) {
			var read = 0;
			var lis = [];
			layui.use('flow', function() {
				var flow = layui.flow;
				flow.load({
					elem: '#LAY_demo1', //流加载容器
					scrollElem: '#LAY_demo1', //滚动条所在元素，一般不用填，此处只是演示需要。
					done: function(page, next) { //执行下一页的回调
						console.log(page);
						//模拟数据插入
						setTimeout(function() {
							$.post(
								rootpath+"/contracmasterMsg/findContracmasterMsgList",
								{
									"pageSize":5,
									"pageIndex":page,
									"masterId":localStorage.getItem("id"),
									"isActive":val
								},
								function(data){
									var len = data.rows.length;
									for(var i = 0; i < len; i++) {
										if(data.rows[i].isActive==0){
											read = parseInt(read)+1;
											lis.push(html.replace("~",data.rows[i].id).replace("~",img).replace("~",data.rows[i].name).replace("~",getDates(data.rows[i].createTime)))

										}else{
											lis.push(html.replace("~",data.rows[i].id).replace("~","").replace("~",data.rows[i].name).replace("~",getDates(data.rows[i].createTime)))
										}
										
									}
									next(lis.join(''), page < parseInt(data.total));
									$("#sumMsg").html(data.total);
									$("#noReadMsg").html(read);
									layer.msg("数据更新成功");
								},"json"
							);

						}, 500);
					}
				});
			});
		}
		function info(id){
			var sumMsg = parseInt($("#sumMsg").html());
			var read = parseInt($("#noReadMsg").html());
			localStorage.removeItem("msgId");
			localStorage.setItem("msgId",id+","+sumMsg+","+read);
			location.href="mes_detail.html";
		}
	</script>

</html>